﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls;
using Silvermoon.Classes;
using Silvermoon.OpenGL;
using Silvermoon.Windows;

namespace Testing.Pages
{
    public class GridPage : DemoWindowBase
    {
        private Grid grid;
        private Label l1, l2, l3, l4;
        private TextBox tb;

        public GridPage()
            : base()
        {
            grid = new Grid { Margin = new Margin(0, 0, 0, 64) };
            grid.Columns.AddRange(GridUnitType.Auto, 200);
            grid.Rows.AddRange(GridUnitType.Auto, GridUnitType.Auto);

            l1 = new Label { AutoSize = false, Text = "Hello", Font = SystemFonts.Normal, Margin = new Margin(0, 0, 0, 5), Alignment = Alignment.Far };
            l2 = new Label { AutoSize = true, Text = "World", Font = SystemFonts.Big, Margin = new Margin(10, 10, 10, null) };
            l3 = new Label { AutoSize = true, Text = "This is a label 12345", Font = SystemFonts.Normal, LineMode = LineMode.WordWrap, TextColor = PhoneColors.White, Background = PhoneColors.Green, LineAlignment = Alignment.Near };
            l4 = new Label { AutoSize = false, Text = "B2", Alignment = Alignment.Center, LineAlignment = Alignment.Center, Margin = Margin.Zero };
            Controls.Add(grid);
            grid.SetControl(l1, 0, 0);
            grid.SetControl(l2, 1, 0);
            grid.SetControl(l3, 0, 1);
            grid.SetControl(l4, 1, 1);
            tb = new TextBox { Margin = new Margin(0, null, 0, 0), Height = 64, AcceptReturn = true };
            Controls.Add(tb);
            tb.TextChanged += new EventHandler(tb_TextChanged);
        }

        void tb_TextChanged(object sender, EventArgs e)
        {
            l3.Text = "@" + tb.Text;
        }

    }
}
